home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 05.zip / BS1 part 5 / IM_Install3.adf / piarc.LZH / animwr1.rexx < prev    next >
OS/2 REXX Batch file  |  1992-04-09  |  4KB  |  156 lines

  1. /*
  2.    This is the opening phase of the ARexx scripts for making ANIM's
  3.    
  4.    This script gets three things from the user and sticks them into a
  5.    file in ram: so the other three phases of the process will know what
  6.    to do.
  7.    
  8.      1 - The name of the ANIM to create or extend is obtained
  9.      2 - The name template to be used for the individual frames is obtained.
  10.      3 - The number of jiffies between frames.
  11.  */
  12.  
  13. /*
  14.  * open rexxsupport.library -- needed for some functions
  15.  */
  16. if ~show('L',"rexxsupport.library") then do
  17.   if addlib('rexxsupport.library',0,-30,0) then do
  18.       /* everything's ok */
  19.     end;
  20.   else do
  21.     say 'We Have A Library Problem, Unable To Load "rexxsupport.library"';
  22.     say 'Cannot operate animr.rexx without this library - sorry!';
  23.     exit 10;
  24.     end;
  25.   end;
  26.  
  27. /*
  28.  * This will automatically direct the script to the proper
  29.  * software, if it is running.
  30.  */
  31. prtnme = 'IP_Port'; /* assume Image Professional */
  32. if show('P','IP_Port') = 0 then do
  33.   if show('P','IM_Port') = 0 then do
  34.     say "Can't find image processor's ARexx port!!!"; /* not running? */
  35.     say "This script requires IP, IM or IM F/c to run!";
  36.     exit(20);
  37.     end;
  38.   else do
  39.     prtnme = 'IM_Port'; /* That's the thing about assumptions... */
  40.     end;                 /* We make em, user's break em.          */
  41.   end;
  42.  
  43. options;
  44. address;
  45.  
  46.   prevpath = 'ram:'; /* put user in ram to start with... */
  47.  
  48.   if show('C',animpath) = 1 then do
  49.     prevpath = getclip(animpath);
  50.     end;
  51.  
  52.   address(prtnme);
  53.  
  54.   options results;
  55.   'filerequest "'||prevpath||'","'||bufname||'",".anim","Make Anim"';
  56.   animfile = result;
  57.   options;
  58.  
  59.   if animfile = 'FR_CANCELLED' then do
  60.     address(prtnme);
  61.     'imtofront';
  62.     exit 0;
  63.     end;
  64.   else do
  65.     animfile = expandfilename(animfile);
  66.     thispath = gimmepath(animfile);
  67.     call setclip(animpath,thispath);
  68.   end;
  69.  
  70.   options results;
  71.   'askprop '||'"# of jiffies (60th / sec) between frames?" 2 1 180'
  72.   jiffies = result;
  73.   options;
  74.  
  75.   res = open(fhandle,animfile,'read');
  76.   if res ~= 0 then do
  77.     call close(fhandle);
  78.     address(prtnme);
  79.     options results;
  80.     'askyn '||'"Create New ANIM" "Append to Existing ANIM"'
  81.     prefs = result;
  82.     if prefs = 0 then do
  83.       address command 'c:delete >nil: '||animfile;
  84.       end;
  85.     if prefs = 1 then do
  86.       options results;
  87.       'askyn '||'"Truncate before appending" "Append as is"'
  88.       prefs = result;
  89.       if prefs = 0 then do
  90.         address command 'cmpi:ANIMWR -t '||jiffies||' '||animfile;
  91.         end;
  92.       end;
  93.     end;
  94.  
  95.   call open(fhandle,'ram:IP_ANIMWR.CFG','write');      /* open the file */
  96.   junk = writeln(fhandle, jiffies);
  97.   junk = writeln(fhandle, animfile);
  98.   call close(fhandle);                     /* close the file    */
  99.  
  100.   address(prtnme);
  101.   'finish';
  102.   exit 0;
  103.  
  104.  
  105. /*
  106.  * gimmepath
  107.  *
  108.  * This takes the provided argument and sucks the path out of it, then
  109.  * returns that path to the caller, sans file name.
  110.  */
  111. gimmepath:
  112.   arg fullnamegx;
  113.     tempgx = reverse(fullnamegx);
  114.     lengx = length(fullnamegx);   /* get length of string */
  115.     slashdex = index(tempgx,'/'); /* first occurance of '/' from right */
  116.     colondex = index(tempgx,':');  /* first occurance of ':' from right */
  117.     seploc = 0; /* assumes current dir, no path supplied */
  118.     if slashdex ~= 0 then do /* we assume we are in a DIR */
  119.       seploc = (lengx - slashdex)+1;
  120.       end;
  121.     else do
  122.       if colondex ~= 0 then do /* we assume we are on a device */
  123.         seploc = (lengx - colondex)+1;
  124.         end;
  125.       end;
  126.   gxname = substr(fullnamegx,seploc+1); /* if you ever need it */
  127.   gxpath = left(fullnamegx,seploc);
  128.   return(gxpath);
  129.  
  130. /*
  131.  * Since this script can't be expected to know where the CD of the user
  132.  * is when this cmd is invoked, we have to check the path the user
  133.  * provides - if it's not specified right from a root, then we have
  134.  * to make it a complete specification from the root.
  135.  */
  136. expandfilename:
  137.   parse arg jfile;
  138.   if index(jfile,':') = 0 then do
  139.     curdir = pragma(D);
  140.     if right(curdir,1) ~= ':' then do
  141.       if right(curdir,1) ~= '/' then do
  142.         if curdir ~= '' then do
  143.           curdir = curdir || '/';
  144.           end;
  145.         end;
  146.       end;
  147.     jfile = curdir||jfile;
  148.     end;
  149.   return(jfile);
  150.  
  151. rvalue:
  152.   wordnum = c2d(readch(fhandle,1)) * 256;
  153.   wordnum = wordnum + c2d(readch(fhandle,1));
  154.   return wordnum;
  155.  
  156.